cmake_minimum_required(VERSION 3.10)

# 项目名称
project(MyProject)

set(CMAKE_TOOLCHAIN_FILE "C:/Code/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)



# 收集所有源文件
file(GLOB SOURCES "src/*.cpp")
file(GLOB HEADERS "src/*.h")
# file(GLOB LIB "lib/*.lib")
# 添加库目标
add_library(IMAGEWRAP SHARED ${SOURCES} ${HEADERS})
# 包含头文件目录
target_include_directories( IMAGEWRAP PRIVATE  ${CMAKE_CURRENT_SOURCE_DIR}/src)
# 设置输出目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

# 设置目标的导出目录
set_target_properties(IMAGEWRAP PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin"
    ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin"
    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin"
)
# # CMake 在生成具有多个构建配置的项目（例如，Visual Studio 或 Xcode 项目）时，默认会为非 Release 配置添加后缀。你可以通过设置以下属性来禁用这些后缀：
# set_target_properties(IMAGEWRAP PROPERTIES
#     DEBUG_POSTFIX ""
# )
target_compile_definitions(IMAGEWRAP PRIVATE IMAGEWRAP_EXPORTS)


set(CMAKE_PREFIX_PATH "C:\\Code\\vcpkg\\packages\\mozjpeg_x64-windows;C:\\Code\\vcpkg\\packages\\openjpeg_x64-windows")

find_package(mozjpeg CONFIG REQUIRED)
target_link_libraries(IMAGEWRAP PRIVATE mozjpeg::jpeg mozjpeg::turbojpeg)

find_package(OpenJPEG CONFIG REQUIRED)
target_link_libraries(IMAGEWRAP PRIVATE openjp2)
